package com.phrp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.phrp.common.ConstantEnum;
import com.phrp.entity.Notice;
import com.phrp.dao.NoticeDao;
import com.phrp.service.NoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.phrp.util.returnResult.ResponseResult;
import com.phrp.util.returnResult.ReturnInfoEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ssc
 * @since 2024-05-05
 */
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeDao, Notice> implements NoticeService {

    @Autowired
    private NoticeDao noticeDao;

    /**
     * 获取公告数据（类型type）
     * @return
     */
    @Override
    public ResponseResult getNoticeData(String type) {
        QueryWrapper<Notice> query = new QueryWrapper<>();
        query.eq("type", type)
                .eq("status","1")
                .orderByDesc("priority")
                .orderByDesc("release_time");

        List<Notice> notices = noticeDao.selectList(query);

        return new ResponseResult(ReturnInfoEnum.SUCCESS,notices);
    }
}
